From 1ba4b3769a22de4d8b48014fcf4976329370d0db Mon Sep 17 00:00:00 2001 From: parkrrrr Date: Tue, 30 Nov 2004 16:16:23 +0000 Subject: [PATCH] More metadata about options --- gpsbabel/defs.h | 39 ++++++++++++++++++++++++++++++--------- gpsbabel/duplicate.c | 4 ++-- gpsbabel/stackfilter.c | 23 ++++++++++++----------- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index 32f895f15..5f008e1ec 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -322,15 +322,36 @@ void vmem_free(vmem_t*); void vmem_realloc(vmem_t*, size_t); -#define ARGTYPE_UNKNOWN 0 -#define ARGTYPE_INT 0x00000001 -#define ARGTYPE_FLOAT 0x00000002 -#define ARGTYPE_STRING 0x00000003 -#define ARGTYPE_BOOL 0x00000004 -#define ARGTYPE_FILE 0x00000005 -#define ARGTYPE_OUTFILE 0x00000006 -#define ARGTYPE_REQUIRED 0x40000000 -#define ARGTYPE_HIDDEN 0x20000000 +#define ARGTYPE_UNKNOWN 0x00000000 +#define ARGTYPE_INT 0x00000001 +#define ARGTYPE_FLOAT 0x00000002 +#define ARGTYPE_STRING 0x00000003 +#define ARGTYPE_BOOL 0x00000004 +#define ARGTYPE_FILE 0x00000005 +#define ARGTYPE_OUTFILE 0x00000006 + +/* REQUIRED means that the option is required to be set. + * See also BEGIN/END_REQ */ +#define ARGTYPE_REQUIRED 0x40000000 + +/* HIDDEN means that the option does not appear in help texts. Useful + * for debugging or testing options */ +#define ARGTYPE_HIDDEN 0x20000000 + +/* BEGIN/END_EXCL mark the beginning and end of an exclusive range of + * options. No more than one of the options in the range may be selected + * or set. If exactly one must be set, use with BEGIN/END_REQ + * Both of these flags set is just like neither set, so avoid doing that. */ +#define ARGTYPE_BEGIN_EXCL 0x10000000 +#define ARGTYPE_END_EXCL 0x08000000 + +/* BEGIN/END_REQ mark the beginning and end of a required range of + * options. One or more of the options in the range MUST be selected or set. + * If exactly one must be set, use with BEGIN/END_EXCL + * Both of these flags set is synonymous with REQUIRED, so use that instead + * for "groups" of exactly one option. */ +#define ARGTYPE_BEGIN_REQ 0x04000000 +#define ARGTYPE_END_REQ 0x02000000 #define ARGTYPE_TYPEMASK 0x00000fff #define ARGTYPE_FLAGMASK 0xfffff000 diff --git a/gpsbabel/duplicate.c b/gpsbabel/duplicate.c index 321834754..5556be28e 100644 --- a/gpsbabel/duplicate.c +++ b/gpsbabel/duplicate.c @@ -31,9 +31,9 @@ static char *correct_coords = NULL; static arglist_t dup_args[] = { {"shortname", &snopt, "Suppress duplicate waypoints based on name", - NULL, ARGTYPE_BOOL}, + NULL, ARGTYPE_BEGIN_REQ | ARGTYPE_BOOL}, {"location", &lcopt, "Suppress duplicate waypoint based on coords", - NULL, ARGTYPE_BOOL}, + NULL, ARGTYPE_END_REQ | ARGTYPE_BOOL}, {"all", &purge_duplicates, "Suppress all instances of duplicates", NULL, ARGTYPE_BOOL}, {"correct", &correct_coords, "Use coords from duplicate points", diff --git a/gpsbabel/stackfilter.c b/gpsbabel/stackfilter.c index d9a82d98a..adb3a9144 100644 --- a/gpsbabel/stackfilter.c +++ b/gpsbabel/stackfilter.c @@ -40,22 +40,23 @@ static int swapdepth = 0; static arglist_t stackfilt_args[] = { {"push", &opt_push, "Push waypoint list onto stack", NULL, - ARGTYPE_BOOL}, - {"copy", &opt_copy, "Copy waypoint list when pushing", NULL, - ARGTYPE_BOOL}, + ARGTYPE_BEGIN_EXCL | ARGTYPE_BEGIN_REQ | ARGTYPE_BOOL}, {"pop", &opt_pop, "Pop waypoint list from stack", NULL, ARGTYPE_BOOL}, - {"append", &opt_append, "Append list when popping", NULL, - ARGTYPE_BOOL}, - {"discard", &opt_discard, "Discard top of stack when popping", - NULL, ARGTYPE_BOOL}, - {"replace", &opt_replace, "Replace list with top of stack (default)", - NULL, ARGTYPE_BOOL}, {"swap", &opt_swap, "Swap waypoint list with item on stack", + NULL, ARGTYPE_END_EXCL | ARGTYPE_END_REQ | ARGTYPE_BOOL}, + {"copy", &opt_copy, "(push) Copy waypoint list", NULL, + ARGTYPE_BOOL}, + {"append", &opt_append, "(pop) Append list", NULL, + ARGTYPE_BEGIN_EXCL | ARGTYPE_BOOL}, + {"discard", &opt_discard, "(pop) Discard top of stack", NULL, ARGTYPE_BOOL}, - {"depth", &opt_depth, "Item to use when swapping", NULL, ARGTYPE_INT}, + {"replace", &opt_replace, "(pop) Replace list (default)", + NULL, ARGTYPE_END_EXCL | ARGTYPE_BOOL}, + {"depth", &opt_depth, "(swap) Item to use (default=1)", + NULL, ARGTYPE_INT}, {"nowarn", &nowarn, "Suppress cleanup warning", NULL, - ARGTYPE_INT | ARGTYPE_HIDDEN}, + ARGTYPE_BOOL | ARGTYPE_HIDDEN}, {0, 0, 0, 0, 0} }; -- 2.30.2